Skip to content

Conversation

@eliandoran
Copy link
Contributor

No description provided.

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jun 21, 2025
@dosubot dosubot bot added BE Issues related to server-side/back-end Type: Scripts & Themes labels Jun 21, 2025
@eliandoran
Copy link
Contributor Author

/gemini review

@eliandoran eliandoran force-pushed the feature/export_with_share_theme branch from d06008b to b1f8d44 Compare October 28, 2025 12:29
@eliandoran eliandoran changed the title Feature/export with share theme Export with share theme Oct 28, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new 'share' export format, which generates a static HTML site using the share theme. This is a significant and well-executed feature. The refactoring of the export logic into a provider-based pattern is a major improvement for maintainability and extensibility. My review includes suggestions to improve an error message, optimize HTML processing, clarify some confusing code, and enhance the accuracy of syntax highlighting.

Comment on lines +308 to 312
for (const codeEl of document.querySelectorAll("pre code")) {
const highlightResult = highlightAuto(codeEl.innerText);
codeEl.innerHTML = highlightResult.value;
codeEl.classList.add("hljs");
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The syntax highlighting uses highlightAuto, which guesses the language and can be inaccurate. Code blocks in Trilium usually have a language-xxx class. This information should be extracted and used with highlight(text, { language: 'xxx' }) for more accurate highlighting, which is consistent with how client-side highlighting is handled.

You'll need to import highlight alongside highlightAuto from @triliumnext/highlightjs.

        for (const codeEl of document.querySelectorAll("pre code")) {
            const language = Array.from(codeEl.classList).find(cls => cls.startsWith('language-'))?.substring('language-'.length);
            const text = codeEl.innerText;
            let highlightResult;
            try {
                highlightResult = language ? highlight(text, { language, ignoreIllegals: true }) : highlightAuto(text);
            }
            catch (e) {
                highlightResult = highlightAuto(text);
            }
            codeEl.innerHTML = highlightResult.value;
            codeEl.classList.add("hljs");
        }

Comment on lines +63 to +67
if (content.length < 100_000) {
content = html.prettyPrint(content, { indent_size: 2 })
}
content = this.rewriteFn(content as string, noteMeta);
return content;

This comment was marked as off-topic.

@eliandoran eliandoran merged commit f4e8fc4 into main Oct 28, 2025
10 checks passed
@eliandoran eliandoran added this to the v0.99.4 milestone Oct 28, 2025
@eliandoran eliandoran deleted the feature/export_with_share_theme branch October 28, 2025 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BE Issues related to server-side/back-end size:XXL This PR changes 1000+ lines, ignoring generated files. Type: Scripts & Themes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants